package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.BbsReply;
import com.zy.pojo.query.bs.BbsReplyQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.BbsReplyService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

@RequestMapping({"bs/bbsReply","m/bs/bbsReply"})
@Controller
public class BbsReplyController extends BaseController {

	@Autowired
	private BbsReplyService bbsReplyService;

	/**
	 * 分页
 	 * 
 	 * @param bbsReplyQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageBbsReply")
	@ResponseBody
	public PageVo pageBbsReply(BbsReplyQuery bbsReplyQuery, Integer start, Integer limit) {
		return this.bbsReplyService.pageBbsReply(bbsReplyQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param bbsReply
	 * @return
	 */
	@RequestMapping(value = "saveBbsReply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveBbsReply(BbsReply bbsReply) {
		try {
			this.bbsReplyService.saveBbsReply(bbsReply);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param bbsReply
	 * @return
	 */
	@RequestMapping(value = "updateBbsReply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateBbsReply(BbsReply bbsReply) {
		try {
			this.bbsReplyService.updateBbsReply(bbsReply);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeBbsReply", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeBbsReply(long id) {
		try {
			this.bbsReplyService.removeBbsReply(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.bbsReplyService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	@RequestMapping("appBbsReply")
	@ResponseBody
	public PageVo appBbsReply(Integer start, Integer limit) {
		return this.bbsReplyService.appBbsReply(this.getCurrentCustomer().getId(), start, limit);
	}

}